feat(anc): direct HTTP download for hotfix with SHA-256 verification - #9233
feat(anc): direct HTTP download for hotfix with SHA-256 verification#9233Abigail Liang (abigailliang-aks-sig-node) wants to merge 5 commits into
Conversation
Windows Unit Test Results 3 files 12 suites 49s ⏱️ Results for commit a06a78b. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Pull request overview
Adds a faster hotfix delivery path for aks-node-controller by allowing direct HTTPS artifact downloads (with SHA-256 verification) when the hotfix config includes an artifacts descriptor, while retaining the existing apt/dnf fallback behavior.
Changes:
- Extend hotfix config parsing to support an
artifactsmap keyed by hotfix version andID-VERSION_ID-GOARCH. - Implement direct HTTP download with URL allowlisting, redirect restrictions, and SHA-256 verification (with hard-fail on integrity violations).
- Add unit tests covering artifact parsing, URL validation, key building, and download/fallback behaviors.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| aks-node-controller/hotfix.go | Adds artifact resolution + direct HTTP download/verify path and associated config structs/helpers. |
| aks-node-controller/hotfix_test.go | Adds tests for artifacts parsing, artifact key derivation, URL validation, and download behavior. |
| aks-node-controller/checkhotfix.go | Propagates/stages artifacts through check-hotfix (LPS + cold-start) into the shared pointer file. |
| aks-node-controller/app.go | Adds an injectable httpDownload hook to allow unit tests to bypass real networking. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…fication Replace the slow apt-get/dnf package manager path (~10-22s) with direct HTTP download (~0.87s) when an artifact descriptor is present in the hotfix config. The new optional `artifacts` field in the hotfix JSON maps version + OS/arch to a download URL and SHA-256 digest. Fallback strategy: - No artifacts or no OS/arch match: fallback to apt/dnf (backward compat) - HTTP network error: fallback to apt/dnf - SHA-256 mismatch or invalid URL: hard fail, keep VHD-baked ANC
Three places were discarding the new artifacts field: 1. LPS staging (line 212): only carried Hotfixes 2. Cold-start fallback (line 448): lenient struct lacked Artifacts 3. writeHotfixConfig serialization: anonymous struct omitted Artifacts All three now pass Artifacts through so download-hotfix can use the direct HTTP download path end-to-end.
Add downloadDir field to App so tests can override the temp file directory (CI lacks /opt/azure/containers/). Update test assertion to expect the copyBinaryAlongside error (vhdBinaryPath not present) while verifying package manager was not invoked.
4f17626 to
a06a78b
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (2)
aks-node-controller/hotfix.go:641
- When
client.Do(req)returns an error, it can still return a non-nilresp. Not closingresp.Bodyin that case can leak connections/file descriptors (and prevent transport reuse).
resp, err := client.Do(req)
if err != nil {
cancel()
return nil, err
}
aks-node-controller/checkhotfix.go:493
- This only preserves
existing.Artifactswhencfg.Artifactsis nil. If the incoming config has an empty-but-non-nil map (e.g. an explicit"artifacts": {}from an upstream serializer), this will overwrite any cloud-init populated artifacts with an empty object.
// Preserve existing artifacts when the incoming config has none (e.g. LPS response
// doesn't include artifacts yet). This mirrors the Version/ScriptsVersion preservation
// and avoids erasing artifacts that cloud-init originally wrote.
if out.Artifacts == nil {
out.Artifacts = existing.Artifacts
}
Summary
artifactsfield to hotfix config JSON for direct HTTP download URLs + SHA-256 checksumsFallback strategy
artifactsmissing or no OS/arch matchExample hotfix config with artifacts
{ "hotfixes": { "202607.02": "202607.02.2" }, "artifacts": { "202607.02.2": { "ubuntu-22.04-amd64": { "url": "https://packages.microsoft.com/...deb", "sha256": "c5c29cd3..." } } } }Future work (separate PRs)
schemaVersion,expiresAt,keyId)artifactsfield during serializationTest plan
buildArtifactKeytests for Ubuntu/AzureLinuxvalidateArtifactURLtests for HTTPS/host allowlist